//------------------------------------------------------------------------------
//  <copyright file="FRIServerTest.cpp" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  </copyright>
//------------------------------------------------------------------------------

#include "stdafx.h"
#include "FRIServerTest.h"

#include <KukaLBR4Definitions.h>
#include <ControllerStateMachineRegisters.h>

/// <summary> Test basic functionality of <c>DoNothing</c> method. </summary>
void FRIServerTest::FRIServerDoNothingTest()
{
	// Assumed current joint position.
	float pJointPosition[NUM_JOINTS] = {1, 2, 3, 4, 5, 6, 7};

	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// Set the current and expected joint positions in the mock
	// On a do nothing, we expect the FRI server to send a joint position
	// command  with values matching that of the arms current position
	for(int i = 0; i < LBR_MNJ; ++i)
	{
		pMockRemote->FRIMsrData.data.msrJntPos[i] = pJointPosition[i];
		pMockRemote->expectedJointPosition[i] = pJointPosition[i];
	}

	pMockRemote->jointPositionCommandReceived = false;

	// call the do nothing method
	// will throw an exception if the commanded position does not equal the expected
	// we set up above
	pFriServer->DoNothing();

	// ensure that a position command was actually sent.
	KUKALBR4NATIVEASSERT(pMockRemote->jointPositionCommandReceived, "Position command received on DoNothing()");

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test basic functionality of <c>DoPositionControl</c> method. </summary>
void FRIServerTest::FRIServerDoPositionControlTest()
{
	// Assumed current joint position.
	float pJointPositions[NUM_JOINTS] = {10, 20, 30, 40, 50, 60, 70};

	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// Set the expected joint positions in the mock
	for(int i = 0; i < LBR_MNJ; ++i)
	{
		pMockRemote->expectedJointPosition[i] = pJointPositions[i];
	}

	pMockRemote->jointPositionCommandReceived = false;

	// call the DoPositionControlMethod with a double array that equals the expected
	// joint positions
	// will throw an exception if the commanded position does not equal the expected
	// we set up above
	double pJointPositionsDouble[NUM_JOINTS];

	for(int i = 0; i < NUM_JOINTS; ++i)
	{
		pJointPositionsDouble[i] = (double)pJointPositions[i];
	}

	pFriServer->DoPositionControl(pJointPositionsDouble);

	// ensure that a position command was actually sent.
	KUKALBR4NATIVEASSERT(pMockRemote->jointPositionCommandReceived, "Position command received on DoNothing()");

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test basic functionality of <c>WaitOnFRIConnect</c> method. </summary>
void FRIServerTest::FRIServerWaitOnFRIConnectTest()
{
	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// This should just immediately return
	pFriServer->WaitOnFRIConnect();

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test basic functionality of <c>GetFRIRequest</c> method. </summary>
void FRIServerTest::FRIServerGetFRIRequestTest()
{
	int i;

	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// Create a set of registers for FRI feedback (different than the set of registers that the KukaLBR4Controlelr
	// provides as they do not include any of the state machine registers).
	ControllerStateMachineRegisters<double> *pFeedbackRegisters = new ControllerStateMachineRegisters<double>(
		KukaLBR4PlusFeedbackRegisters::NumberOfFeedbackRegisters,
		(unsigned int *)&(KukaLBR4PlusRegisterSizes[KukaLBR4PlusWorkingRegisters::NumberOfWorkingRegisters]));
	
	// srand cannot take a value larger than unsigned int, so no reason to use GetTickCount64()
#pragma warning(suppress: 28159)
	srand(GetTickCount());

	/// Populate the FRI feedback with random data
	for(i = 0; i<CARTESIAN_DIM; ++i)
	{
		pMockRemote->FRIMsrData.data.estExtTcpFT[i] = (float)rand();
	}

	for (i = 0; i < CARTESIAN_FRAME_LENGTH; ++i)
	{
		pMockRemote->FRIMsrData.data.cmdCartPosFriOffset[i] = (float)rand();
		pMockRemote->FRIMsrData.data.cmdCartPos[i] = (float)rand();
		pMockRemote->FRIMsrData.data.msrCartPos[i] = (float)rand();
	}

	for(i = 0; i<NUM_JOINTS; ++i)
	{
		pMockRemote->FRIMsrData.data.cmdJntPosFriOffset[i] = (float)rand();
		pMockRemote->FRIMsrData.data.cmdJntPos[i] = (float)rand();
		pMockRemote->FRIMsrData.robot.temperature[i] = (float)rand();
		pMockRemote->FRIMsrData.data.estExtJntTrq[i] = (float)rand();
		pMockRemote->FRIMsrData.data.msrJntPos[i] = (float)rand();
		pMockRemote->FRIMsrData.data.msrJntTrq[i] = (float)rand();
	}

	pMockRemote->FRIMsrData.robot.control = rand();
	pMockRemote->FRIMsrData.intf.desiredMsrSampleTime = (float)rand();
	pMockRemote->FRIMsrData.robot.power = rand();
	pMockRemote->FRIMsrData.intf.state = rand();

	for(int i = 0; i<NUM_JOINTS*CARTESIAN_DIM; ++i)
	{
		pMockRemote->FRIMsrData.data.jacobian[i] = (float)rand();
		pMockRemote->FRIMsrData.data.massMatrix[i] = (float)rand();
	}

	pMockRemote->FRIMsrData.intf.safetyLimits = (float)rand();
	pMockRemote->FRIMsrData.intf.timestamp = (float)rand();
	pMockRemote->FRIMsrData.intf.quality = rand();

	pFriServer->GetFRIRequest(pFeedbackRegisters->GetRegisters());

	for(i = 0; i<CARTESIAN_DIM; ++i)
	{
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::EstimatedTCPForceTorqueRegister)[i] == 
			pMockRemote->FRIMsrData.data.estExtTcpFT[i], "EsitmatedTCPForceTorqueRegister is correct");
	}

	for (i = 0; i<CARTESIAN_FRAME_LENGTH; ++i)
	{
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::CommandedCartesianOffsetRegister)[i] ==
			pMockRemote->FRIMsrData.data.cmdCartPosFriOffset[i], "CommandedCartestianOffsetRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::CommandedCartesianPositionRegister)[i] ==
			pMockRemote->FRIMsrData.data.cmdCartPos[i], "CommandedCartesianPositionRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::MeasuredCartesianPositionRegister)[i] ==
			pMockRemote->FRIMsrData.data.msrCartPos[i], "MeasuredCartesainPositionRegister is correct");
	}

	for(i = 0; i<NUM_JOINTS; ++i)
	{
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::CommandedJointOffsetRegister)[i] ==
			pMockRemote->FRIMsrData.data.cmdJntPosFriOffset[i], "CommandedJointOffsetRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::CommandedJointPositionRegister)[i] ==
			pMockRemote->FRIMsrData.data.cmdJntPos[i], "CommandedJointPositionRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::JointTemperatureRegister)[i] == 
			pMockRemote->FRIMsrData.robot.temperature[i], "JointTemperatureRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::MeasuredExternalJointTorqueRegister)[i] ==
			pMockRemote->FRIMsrData.data.estExtJntTrq[i], "MeauredExternalJointTorqueRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::MeasuredJointPositionRegister)[i] ==
			pMockRemote->FRIMsrData.data.msrJntPos[i], "MeasuredJointPositionRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::MeasuredJointTorqueRegister)[i] ==
			pMockRemote->FRIMsrData.data.msrJntTrq[i], "MeasuredJointTorqueRegister is correct");
	}

	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::ControllerStrategyRegister)[0] == 
		pMockRemote->FRIMsrData.robot.control, "ControlStrategyRegister is correct");
	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::CycleTimeInMsRegister)[0] == 
		pMockRemote->FRIMsrData.intf.desiredMsrSampleTime * 1000.0, "CycleTimeInMsRegister is correct");
	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::DrivePowerBitFieldRegister)[0] ==
		pMockRemote->FRIMsrData.robot.power, "DrivePowerBitFieldRegister is correct");
	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::FRIStateRegister)[0] == 
		pMockRemote->FRIMsrData.intf.state, "FRIStateRegister is correct");

	for(int i = 0; i<NUM_JOINTS*CARTESIAN_DIM; ++i)
	{
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::JacobianRegister)[i] ==
			pMockRemote->FRIMsrData.data.jacobian[i], "JacobianRegister is correct");
		KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::MassMatrixRegister)[i] ==
			pMockRemote->FRIMsrData.data.massMatrix[i], "MassMatrixRegister is correct");
	}

	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::SafetyLimitInPercentRegister)[0] ==
		pMockRemote->FRIMsrData.intf.safetyLimits, "SafetyLimitInPercentRegister is correct");
	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::TimestampInMsRegister)[0] ==
		pMockRemote->FRIMsrData.intf.timestamp*1000, "TimeStampInMsRegister is correct");
	KUKALBR4NATIVEASSERT(pFeedbackRegisters->GetRegister(KukaLBR4PlusFeedbackRegisters::UDPQualityRegister)[0] ==
		pMockRemote->FRIMsrData.intf.quality, "UDPQualityRegister is correct");

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
	delete pFeedbackRegisters;
}

/// <summary> Test basic functionality of <c>DoPositionControl</c> method. </summary>
void FRIServerTest::FRIServerGetFRIQualityTest()
{
	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	pMockRemote->FRIQuality = FRI_QUALITY::FRI_QUALITY_PERFECT;
	KUKALBR4NATIVEASSERT(pFriServer->GetFRIQuality() == FRIQuality::FRIQualityPerfect, "FRIQuality is correct.");

	pMockRemote->FRIQuality = FRI_QUALITY::FRI_QUALITY_BAD;
	KUKALBR4NATIVEASSERT(pFriServer->GetFRIQuality() == FRIQuality::FRIQualityBad, "FRIQuality is correct.");

	pMockRemote->FRIQuality = FRI_QUALITY::FRI_QUALITY_OK;
	KUKALBR4NATIVEASSERT(pFriServer->GetFRIQuality() == FRIQuality::FRIQualityOK, "FRIQuality is correct.");

	pMockRemote->FRIQuality = FRI_QUALITY::FRI_QUALITY_UNACCEPTABLE;
	KUKALBR4NATIVEASSERT(pFriServer->GetFRIQuality() == FRIQuality::FRIQualityUnaceptable, "FRIQuality is correct.");

	pMockRemote->FRIQuality = FRI_QUALITY::FRI_QUALITY_INVALID;
	KUKALBR4NATIVEASSERT(pFriServer->GetFRIQuality() == FRIQuality::FRIQualityInvalid, "FRIQuality is correct.");

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test basic functionality of <c>DoCartesianImpedanceControl</c> method. </summary>
void FRIServerTest::FRIServerDoCartesianImpedanceControlTest()
{
	const float xPos = 10;
	const float yPos = 20;
	const float zPos = 30;

	// pick a Cartesian position
	float pCartesianPositions[CARTESIAN_FRAME_LENGTH] = {1, 0, 0, xPos, 0, 1, 0, yPos, 0, 0, 1, zPos};

	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();

	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// Set the expected cartesian positions in the mock
	for(int i = 0; i < CARTESIAN_FRAME_LENGTH; ++i)
	{
		pMockRemote->expectedCartesianPosition[i] = pCartesianPositions[i];
	}

	// call the DoCartesianImpedanceControl with a double array that equals the expected
	// positions
	// will throw an exception if the commanded position does not equal the expected
	// we set up above
	double pCartesianPositionsDouble[CARTESIAN_FRAME_LENGTH];

	for(int i = 0; i < CARTESIAN_FRAME_LENGTH; ++i)
	{
		pCartesianPositionsDouble[i] = (double)pCartesianPositions[i];
	}

	pFriServer->DoCartesianImpedanceControl(pCartesianPositionsDouble, NULL, NULL, NULL);

	// ensure that a position command was actually sent.
	KUKALBR4NATIVEASSERT(pMockRemote->doCartesianImpedanceControlCount > 0, "Cartesian impeance control command received");

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test basic functionality of <c>DoKrlCartesianImpedanceControl</c> method. </summary>
void FRIServerTest::FRIServerDoKrlCartesianImpedanceControlTest()
{
	const float xPos = 10;
	const float yPos = 20;
	const float zPos = 30;

	const int sequenceNumber = 42;

	SimpleMockFRIRemote *pMockRemote = new SimpleMockFRIRemote();
	FRIServer *pFriServer = new FRIServer(pMockRemote);

	// Test general case
	double pCartesianPositions[CARTESIAN_FRAME_LENGTH] = {0.5, -0.8536, 0.1464, xPos, 0.5, 0.1464, -0.8536, yPos, 0.7071, 0.5, 0.5, zPos};

	// Set the expected real registers in the mock
	pMockRemote->expectedToKRLReal[0] = 1000*xPos; // X
	pMockRemote->expectedToKRLReal[1] = 1000*yPos; // Y
	pMockRemote->expectedToKRLReal[2] = 1000*zPos; // Z
	pMockRemote->expectedToKRLReal[3] = 45; // A
	pMockRemote->expectedToKRLReal[4] = -45; // B
	pMockRemote->expectedToKRLReal[5] = 45; // C
	pMockRemote->expectedToKRLInt[0] = sequenceNumber; // sequence number
	pMockRemote->expectedToKRLInt[1] = 5; // status
	pMockRemote->expectedToKRLInt[2] = 61; // turn

	// will throw an exception if the commanded position does not equal the expected
	// we set up above
	pFriServer->DoKrlCartesianImpedanceControl(pCartesianPositions, sequenceNumber);

	// Test special case where B is +/- 90 
	float sp4 = (float)sin(M_PI_4);
	double pSpecialCartesianPositions[CARTESIAN_FRAME_LENGTH] = {0, -sp4, sp4, xPos, 0, -sp4, -sp4, yPos, 1, 0, 0, zPos};

	// Set the expected real registers in the mock
	pMockRemote->expectedToKRLReal[0] = 1000*xPos; // X
	pMockRemote->expectedToKRLReal[1] = 1000*yPos; // Y
	pMockRemote->expectedToKRLReal[2] = 1000*zPos; // Z
	pMockRemote->expectedToKRLReal[3] = 0; // A
	pMockRemote->expectedToKRLReal[4] = -90; // B
	pMockRemote->expectedToKRLReal[5] = 135; // C
	pMockRemote->expectedToKRLInt[0] = sequenceNumber; // sequence number
	pMockRemote->expectedToKRLInt[1] = 5; // status
	pMockRemote->expectedToKRLInt[2] = 61; // turn

	// will throw an exception if the commanded position does not equal the expected
	// we set up above
	pFriServer->DoKrlCartesianImpedanceControl(pSpecialCartesianPositions, sequenceNumber);

	// deleting pFriServer also deletes pMockRemote
	delete pFriServer;
}

/// <summary> Test that methods behave properly when pFRIRemote is null </summary>
void FRIServerTest::FRIServerInvalidFRIRemoteTest()
{
	FRIServer *pFRIServer = new FRIServer(new SimpleMockFRIRemote());
	pFRIServer->CloseFRI();

	KUKALBR4NATIVEASSERT(pFRIServer->WaitOnFRIConnect() == -1, "WaitOnFRIConnect() returns -1 when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->GetFRIRequest(NULL) == -1, "GetFRIRequest() returns -1 when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->DoNothing() == -1, "DoNothing() returns -1 when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->GetFRIQuality() == FRIQuality::FRIQualityInvalid, "GetFRIQuality() returns FRIQuality::FRIQualityInvalid when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->DoPositionControl(NULL) == FRI_STATE_INVALID, "DoPositionControl() returns FRI_STATE_INVALID when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->DoCartesianImpedanceControl(NULL, NULL, NULL, NULL) == FRI_STATE_INVALID, "DoCartesianImpedanceControl() returns FRI_STATE_INVALID when FRIRemote has been closed.");
	KUKALBR4NATIVEASSERT(pFRIServer->DoKrlCartesianImpedanceControl(NULL, 0) == FRI_STATE_INVALID, "DoKrlCartesianImpedanceControl() returns FRI_STATE_INVALID when FRIRemote has been closed.");
}

/// <summary> Test basic functionality of <c>DoNothing</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerDoNothingTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerDoNothingTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test basic functionality of <c>DoPositionControl</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerDoPositionControlTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerDoPositionControlTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test basic functionality of <c>WaitOnFRIConnect</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerWaitOnFRIConnectTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerWaitOnFRIConnectTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test basic functionality of <c>WaitOnFRIConnect</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerGetFRIRequestTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerGetFRIRequestTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

// <summary> Test basic functionality of <c>WaitOnFRIConnect</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerGetFRIQualityTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerGetFRIQualityTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test basic functionality of <c>DoCartesianImpdedanceControl</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerCartesianImpedanceControlTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerDoCartesianImpedanceControlTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test basic functionality of <c>DoKrlCartesianImpdedanceControl</c> method. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerKrlCartesianImpedanceControlTest(char *resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerDoKrlCartesianImpedanceControlTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}

/// <summary> Test that methods behave properly when FRI server has been closed. </summary>
/// <param name="resultString"> buffer for a failure message or indication that test passed. </param>
/// <param name="buffersize"> length of <c>resultString</c> buffer. </param>
void FRIServerInvalidFRIRemoteTest(char* resultString, int bufferSize)
{
	try
	{
		FRIServerTest::FRIServerInvalidFRIRemoteTest();
	}
	catch (const char *ex)
	{
		strcpy_s(resultString, bufferSize, ex);
		return;
	}

	strcpy_s(resultString, bufferSize, KukaLBR4NativeTests::pPassString);
}
